<?php

namespace Home\Controller;

/**
 * 默认
 * @auth zhuliu
 */
class Page extends \App\Application {

	public function __construct($appName, $controllerName, $actionName) {
		parent::__construct($appName, $controllerName, $actionName);
	}

	/**
	 * 默认
	 * @param  void
	 * @return string
	 */
	public function index() {
		return $this->json(ECODE_SUCCESS, []);
	}

	public function wx() {
		$signature = $this->get('signature', TRUE);
		$timestamp = $this->get('timestamp', TRUE);
		$nonce = $this->get('nonce', TRUE);
		$echostr = $this->get('echostr', TRUE);

		$token = 'w1pWfCnBP1P2ArtAW2A1jFa9ZScqCbTH';
		$tmpArr = array($token, $timestamp, $nonce);
		sort($tmpArr, SORT_STRING);
		$tmpStr = implode( $tmpArr );
		$tmpStr = sha1( $tmpStr );

		if( $tmpStr == $signature ){
			return $echostr;
		}else{
			return false;
		}
	}
}
